﻿using Client.Common.Common.Event;
using Client.Common.Extensions;
using Prism.Events;
using Prism.Ioc;
using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Client.Todo.ViewModels
{
    /// <summary>
    /// 导航实现的VM
    /// </summary>
    public class NavigationViewModel :BindableBase, INavigationAware
    {
        private readonly IContainerProvider containerProvider;

        public readonly IEventAggregator eventAggregator;

        /// <summary>
        /// 导航类VM实现
        /// </summary>
        public NavigationViewModel(IContainerProvider containerProvider)
        {
            this.containerProvider = containerProvider;
            this.eventAggregator = containerProvider.Resolve<IEventAggregator>();
        }

        public virtual bool IsNavigationTarget(NavigationContext navigationContext)
        {
            return true;
        }

        public virtual void OnNavigatedFrom(NavigationContext navigationContext)
        {

        }

        public virtual void OnNavigatedTo(NavigationContext navigationContext)
        {

        }

        public virtual void UpdateLoading(bool isOpen)
        {
            eventAggregator.UpdateLoading(new UpdateModel()
            {
                IsOpen = isOpen
            });
        }
    }
}
